<%@page import="com.pethub.controller.web.petDetail"%>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib uri="http://www.rapid-framework.org.cn/rapid" prefix="rapid" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="mvc" %>
<%@ include file="nav.jsp"%>
<%@ include file="logo.jsp"%>
<%@ include file="item.jsp"%>
<%@ include file="footer.jsp" %>
<rapid:override name="contentContainer">
<div class="row">
     <div class="col-sm-12 minBox" >
     	<div class="center">
     		<h1 style="color: #0ea6b5 !important;font-weight: 800 !important;font-size: 40px !important; line-height: 50px !important;letter-spacing: 0 !important;">创建宠物记录</h1>
     	</div>
     	
     	<fieldset class="form-wrapper" id="edit-pet-recs">
     		<legend><span class="fieldset-legend"><%UserInfo userInfo = (UserInfo)session.getAttribute("user");if(userInfo != null){out.print(userInfo.getName());}else{out.print("null");}%>的记录</span></legend>	  
	      	<mvc:form modelAttribute='petDetail' role="form" action="/pethub/node/add/pet-record-finished" method="post" class="registration-form">
			   <div class="col-sm-11 col-md-11 col-lg-11 registBox">
			   		<div class="col-sm-12 col-md-5 col-lg-5 registMinBox">
				   		<div class="form-group">
							<mvc:label path="petRecordTitle" for="petRecordTitle" class="control-label">将要上传文件的标题:</mvc:label>
							<div class=" buttonMin">
								<mvc:input path="petRecordTitle" id='petRecordTitle' type="petRecordTitle" placeholder="张三" class="form-control" />
							</div>
							<div class="clearfix"></div>
						</div>
					</div>
					<div class="clearfix"></div>
					<div class="col-sm-12 col-md-5 col-lg-5 registMinBox">
						<div class="row" style="display:none" id="imageCheck"></div>
		                <div class="form-group ">
		                    <label class=" control-lable " for="file">上传文件</label>
		                    <div >
		                        <input type="file" id="multipartFile" class="form-control input-sm"/>
		                    </div>
		                    <div class="col-md-2 col-lg-2 col-xs-2 ">
				                <div class="form-actions ">
				                    <input type="button" value="上传" class="btn btn-primary btn-sm" onclick="checkUpload(this)">
				                </div>
				            </div>
				            <div class="clearfix"></div>
		                </div>
		            </div>
		            <div class="clearfix"></div>
		            <div class="col-sm-12 col-md-5 col-lg-5 float-left registMinBox">
				   		<div class="form-group">
							<mvc:label path="petRecordTitle" for="petRecordTitle" class="control-labe ">简要说明:</mvc:label>
							<div class=" buttonMin">
								<mvc:textarea path="petRecordTitle" cols="100%" rows="10"/>
							</div>
							<div class="clearfix"></div>
						</div>
					</div>
					
			     <div class="clearfix"></div>
			     <div>
			     	<button id="submitBtn" type="submit" class="btn btn-default float-left submitButton">提交</button>
			     </div>
			     <div class="clearfix"></div>
			     </div>
	   		</mvc:form>
	    </fieldset>
     	
   
     </div>
 </div>
</rapid:override>
<%@ include file="base.jsp" %>
<script type="text/javascript">
	function checkUpload(){
		console.log("checkupload");
		var file=document.getElementById("multipartFile");
		
		  var oMyForm = new FormData();
		  oMyForm.append("file", file.files[0]);

		  $.ajax({
		    url: "/pethub/fileUploadCheck",
		    data: oMyForm,
		    dataType: 'multipart/form-data',
		    processData: false,
		    contentType: false,
		    type: 'POST',
		    success: function(msg) {
	        	alert(msg)
	            alert("File has been uploaded successfully");
	        },
	        error:function(msg) {
	        	alert(msg)
	        	console.log(msg)
	        }
		  });
	
	}
</script>